﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FeatureModelCore.FMInterface;

namespace FeatureModelCore.FMCrossTreeConstraint
{
    public class CrossTreeConstraintInfoForNode
    {
        public IFeature NodeA { get { return _nodeA; } }
        public IFeature NodeB { get { return _nodeB; } }
        public IFeature InnerNode
        {
            get
            {
                if (_infoType != CrossTreeConstraintInfoType.Outer)
                    return null;
                if (_nodeA == null)
                {
                    return _nodeB;
                }
                return _nodeA;
            }
        }

        public CrossTreeConstraintInfoType InfoType { get { return _infoType; } internal set { _infoType = value; } }
        public IConstraint CrossTreeConstraint { get { return _cons; } }

        private IFeature _nodeA;
        private IFeature _nodeB;

        private IConstraint _cons;
        private CrossTreeConstraintInfoType _infoType;
        

        internal CrossTreeConstraintInfoForNode(IConstraint cons
            , IFeature nodeA, IFeature nodeB
            , CrossTreeConstraintInfoType type)
        {
            _cons = cons;
            _infoType = type;
            _nodeA = nodeA;
            _nodeB = nodeB;
        }


        public override bool Equals(object obj)
        {
            if (ReferenceEquals(this, obj))
            {
                return true;
            }
            CrossTreeConstraintInfoForNode info =obj as CrossTreeConstraintInfoForNode;
            if (obj == null)
            {
                return false;
            }
            return ReferenceEquals(this._cons, info._cons);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

    }
}
